GROUP NUMBER: 3193
Sydney Oghenetega Anuyah sydneyanuyah@gmail.com
Aakash Bhattacharya abhattac92@gmail.com
Oluwarotimi John Ogundele oluwarotimi.ogundele@gmail.com
3.1 Macroeconomic Variable
Exchange rates between the Euro and the US dollar is a macroeconomic variable because it represents the relationship between two major world currencies, which has an impact on global trade and the flow of capital. In particular, it can affect the demand for oil and its price.
Oil is typically priced in US dollars, so a change in the exchange rate between the Euro and the dollar can affect the price of oil in Euro terms. For example, if the Euro strengthens against the dollar, it takes fewer Euros to buy a barrel of oil priced in dollars, which can lead to an increase in demand for oil from Euro-zone countries, and an increase in the price of oil in Euro terms. Conversely, if the Euro weakens against the dollar, it takes more Euros to buy a barrel of oil priced in dollars, which can lead to a decrease in demand for oil from Euro-zone countries, and a decrease in the price of oil in Euro terms.
Therefore, exchange rates between the Euro and the US dollar is an important macroeconomic variable to consider when forecasting the price of oil, as it can have a significant impact on the supply and demand dynamics of the global oil market.
import yfinance as yf
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import plotly.express as px
Microeconomic Variable
Using the Euro and considering the oil prices in the European nation is really fitting to explain the task at hand.
Stock prices of STOXX Europe 600 is a microeconomic variable because it represents the performance of a specific group of companies within a particular sector. The STOXX Europe 600 is an index of European stocks representing large, mid, and small capitalization companies across 18 European countries, covering approximately 90% of the European market capitalization. The stock prices of these companies are influenced by microeconomic factors such as individual company performance, management decisions, and competition within their respective industries.
Justification The STOXX Europe 600 is a broad-based stock market index that represents the performance of large, mid, and small-cap companies across 17 European countries, including both developed and emerging markets. The index covers a wide range of sectors, including energy, financials, healthcare, and technology, among others. Therefore, it could be a good option to consider in this case because:
Diversification: The STOXX Europe 600 provides exposure to a diverse range of companies across multiple sectors and countries. By investing in this index, you could potentially reduce your portfolio's concentration risk and benefit from the broad-based growth of the European economy.
Exposure to the energy sector: As mentioned, the STOXX Europe 600 includes companies from a variety of sectors, including energy. Therefore, it could provide exposure to the European energy sector, which could be relevant when considering the factors that affect the price of oil globally.
Liquidity: The STOXX Europe 600 is a widely followed index with a large number of constituents, which could make it more liquid and tradable than individual stocks. This could be particularly important if you are looking to invest in or trade the index.
Benchmark: The STOXX Europe 600 is widely used as a benchmark for European equities and is tracked by a variety of investment products, including mutual funds and exchange-traded funds (ETFs). Therefore, it could be a useful reference point for evaluating the performance of your investments in the European market.
Overall, the STOXX Europe 600 could be a good option to consider in this case because it provides exposure to a diversified set of European companies across multiple sectors, including energy.
However, the stock prices of STOXX Europe 600 are also related to macroeconomic variables. The performance of companies within the index is influenced by macroeconomic factors such as GDP growth, inflation, interest rates, and government policies. For example, when the economy is growing, companies are likely to perform well, leading to an increase in their stock prices. On the other hand, a recession can lead to a decrease in company profits and a subsequent decline in their stock prices. Additionally, government policies such as tax rates and regulations can also affect the performance of companies and their stock prices. Therefore, while stock prices of STOXX Europe 600 are primarily influenced by microeconomic factors, they are also linked to macroeconomic variables.
Question 4 As a group, the team writes a dictionary of the data used and a table showing the data, frequency, source, start date, end date, and other relevant fields.
The source of the macroeconomic data is yahoo finance, and we take the start date from January 1st 2010 up till May 5th 2023 with a daily interval. The dictionary and the table is shown below and the keys to identify them.
The source of the microeconomic data is yahoo finance, and we take the start date from January 1st 2010 up till May 5th 2023 with a daily interval. The dictionary and the table is shown below and the keys to identify them.
# Download Euro to USD exchange rate data from Yahoo Finance
eur_usd = yf.download('EURUSD=X', start='2010-01-01', end='2023-05-01', interval='1d')
eur_usd
[*********************100%***********************] 1 of 1 completed
| Open | High | Low | Close | Adj Close | Volume | |
|---|---|---|---|---|---|---|
| Date | ||||||
| 2010-01-01 | 1.432706 | 1.440196 | 1.432706 | 1.438994 | 1.438994 | 0 |
| 2010-01-04 | 1.431004 | 1.445191 | 1.426208 | 1.442398 | 1.442398 | 0 |
| 2010-01-05 | 1.442710 | 1.448310 | 1.435194 | 1.436596 | 1.436596 | 0 |
| 2010-01-06 | 1.436596 | 1.443460 | 1.429123 | 1.440403 | 1.440403 | 0 |
| 2010-01-07 | 1.440300 | 1.444481 | 1.430206 | 1.431803 | 1.431803 | 0 |
| ... | ... | ... | ... | ... | ... | ... |
| 2023-04-24 | 1.099227 | 1.103424 | 1.096876 | 1.099227 | 1.099227 | 0 |
| 2023-04-25 | 1.105950 | 1.106807 | 1.096924 | 1.105950 | 1.105950 | 0 |
| 2023-04-26 | 1.097839 | 1.109410 | 1.096924 | 1.097839 | 1.097839 | 0 |
| 2023-04-27 | 1.104728 | 1.106562 | 1.099421 | 1.104728 | 1.104728 | 0 |
| 2023-04-28 | 1.103205 | 1.104374 | 1.096563 | 1.103205 | 1.103205 | 0 |
3471 rows × 6 columns
eur_usd_macro_dict = eur_usd.to_dict()
eur_usd_macro_dict.keys()
dict_keys(['Open', 'High', 'Low', 'Close', 'Adj Close', 'Volume'])
# Download STOXX Europe 600 stock price data from Yahoo Finance
stoxx_600 = yf.download('^STOXX', start='2010-01-01', end='2023-05-01', interval='1d')
stoxx_600
[*********************100%***********************] 1 of 1 completed
| Open | High | Low | Close | Adj Close | Volume | |
|---|---|---|---|---|---|---|
| Date | ||||||
| 2010-01-04 | 254.240005 | 257.649994 | 254.240005 | 257.649994 | 257.649994 | 0 |
| 2010-01-05 | 257.399994 | 258.209991 | 256.429993 | 257.589996 | 257.589996 | 0 |
| 2010-01-06 | 258.079987 | 258.609985 | 256.970001 | 257.959991 | 257.959991 | 0 |
| 2010-01-07 | 257.320007 | 258.790009 | 255.860001 | 258.040009 | 258.040009 | 0 |
| 2010-01-08 | 258.570007 | 259.829987 | 257.500000 | 259.149994 | 259.149994 | 0 |
| ... | ... | ... | ... | ... | ... | ... |
| 2023-04-24 | 468.329987 | 469.640015 | 467.329987 | 468.970001 | 468.970001 | 162760500 |
| 2023-04-25 | 468.320007 | 468.320007 | 465.970001 | 467.079987 | 467.079987 | 177789500 |
| 2023-04-26 | 466.390015 | 466.390015 | 461.209991 | 463.209991 | 463.209991 | 218974700 |
| 2023-04-27 | 462.790009 | 464.989990 | 462.239990 | 464.029999 | 464.029999 | 181130500 |
| 2023-04-28 | 464.140015 | 466.640015 | 461.399994 | 466.640015 | 466.640015 | 234537800 |
3345 rows × 6 columns
# Download crude oil price data from the US Energy Information Administration
oil_price = pd.read_csv('https://raw.githubusercontent.com/Sydney-Anuyah/Financial-Engineering-Risk-Management/main/EuropeBrentOilSpotPrice.csv')
oil_price
| Date | oil_price | |
|---|---|---|
| 0 | Jan-2010 | 76.17 |
| 1 | Feb-2010 | 73.75 |
| 2 | Mar-2010 | 78.83 |
| 3 | Apr-2010 | 84.82 |
| 4 | May-2010 | 75.95 |
| ... | ... | ... |
| 155 | Dec-2022 | 80.92 |
| 156 | Jan-2023 | 82.50 |
| 157 | Feb-2023 | 82.59 |
| 158 | Mar-2023 | 78.43 |
| 159 | Apr-2023 | 84.64 |
160 rows × 2 columns
stoxx_600_micro_dict = stoxx_600.to_dict()
stoxx_600_micro_dict.keys()
dict_keys(['Open', 'High', 'Low', 'Close', 'Adj Close', 'Volume'])
DataDictionary = {
'Oil Price': {
'Variable Type': 'Financial Variable',
'description': 'Price of oil in US Dollars per barrel since the US is the standard price',
'frequency': 'Monthly',
'source': 'Europe Energy Information Association',
'start_date': '2010-January',
'end_date': '2023-April',
'other_fields': 'Nominal dollars per barrel'
},
'Euro to Dollar': {
'Variable Type': 'Macroeconomic Variable',
'description': 'Exchange Rate from Euro to Dollar',
'frequency': 'Daily',
'source': 'yfinance',
'start_date': '2010-January',
'end_date': '2023-April',
'other_fields': 'Adjusted Close: Euro/Dollar'
},
'STOXX Europe 600': {
'Variable Type': 'Microeconomic Variable',
'description': 'Stock index of European stocks designed by STOXX oil Ltd',
'frequency': 'Daily',
'source': 'yfinance',
'start_date': '2010-January',
'end_date': '2023-April',
'other_fields': 'Adjusted Close Prices'}
}
# Create DataFrame from macro_data_dict dictionary
macro_df = pd.DataFrame.from_dict(DataDictionary, orient='index')
macro_df.index.name = 'Variable Name'
# Display DataFrame as table
print(macro_df.to_markdown())
| Variable Name | Variable Type | description | frequency | source | start_date | end_date | other_fields | |:-----------------|:-----------------------|:-------------------------------------------------------------------------|:------------|:--------------------------------------|:-------------|:-----------|:----------------------------| | Oil Price | Financial Variable | Price of oil in US Dollars per barrel since the US is the standard price | Monthly | Europe Energy Information Association | 2010-January | 2023-April | Nominal dollars per barrel | | Euro to Dollar | Macroeconomic Variable | Exchange Rate from Euro to Dollar | Daily | yfinance | 2010-January | 2023-April | Adjusted Close: Euro/Dollar | | STOXX Europe 600 | Microeconomic Variable | Stock index of European stocks designed by STOXX oil Ltd | Daily | yfinance | 2010-January | 2023-April | Adjusted Close Prices |
macro_df
| Variable Type | description | frequency | source | start_date | end_date | other_fields | |
|---|---|---|---|---|---|---|---|
| Variable Name | |||||||
| Oil Price | Financial Variable | Price of oil in US Dollars per barrel since th... | Monthly | Europe Energy Information Association | 2010-January | 2023-April | Nominal dollars per barrel |
| Euro to Dollar | Macroeconomic Variable | Exchange Rate from Euro to Dollar | Daily | yfinance | 2010-January | 2023-April | Adjusted Close: Euro/Dollar |
| STOXX Europe 600 | Microeconomic Variable | Stock index of European stocks designed by STO... | Daily | yfinance | 2010-January | 2023-April | Adjusted Close Prices |
Step 5
Clean the data. Each person carefully reads Section 4.1 of the paper. Each person is responsible for one part of cleaning the data. Student A will do their part on ALL the data: macroeconomic, microeconomic, and geopolitical. Likewise, Student B will do their part on ALL the data. Likewise, Student C will do their part on all the data. This gives each person a chance to see all the data that was collected. a. Student A focuses on the “extreme outlier” part of cleaning. That is, they will identify values that are extreme compared to the rest of the data. b. Student B focuses on the “bad data” part of cleaning. That is, they will identify values that are wrong, questionable, or duplicated. c. Student C focuses on the “missing values” part of cleaning. That is, they will use a method of imputation, interpolation, or simulation, or some other method, to substitute reasonable values if and when there are missing values.
First, I would like to rename the columns
# Renaming columns of df1
eur_usd = eur_usd.rename(columns={'Adj Close': 'eur_usd_Adj_Close'})
# Renaming columns of df2
stoxx_600 = stoxx_600.rename(columns={'Adj Close': 'stoxx_600_Adj_Close'})
#display the two dataframes
eur_usd.head(2)
| Open | High | Low | Close | eur_usd_Adj_Close | Volume | |
|---|---|---|---|---|---|---|
| Date | ||||||
| 2010-01-01 | 1.432706 | 1.440196 | 1.432706 | 1.438994 | 1.438994 | 0 |
| 2010-01-04 | 1.431004 | 1.445191 | 1.426208 | 1.442398 | 1.442398 | 0 |
stoxx_600.head(2)
| Open | High | Low | Close | stoxx_600_Adj_Close | Volume | |
|---|---|---|---|---|---|---|
| Date | ||||||
| 2010-01-04 | 254.240005 | 257.649994 | 254.240005 | 257.649994 | 257.649994 | 0 |
| 2010-01-05 | 257.399994 | 258.209991 | 256.429993 | 257.589996 | 257.589996 | 0 |
# Joining the two DataFrames on the index
df = pd.merge(eur_usd['eur_usd_Adj_Close'], stoxx_600['stoxx_600_Adj_Close'], left_index=True, right_index=True)
df
| eur_usd_Adj_Close | stoxx_600_Adj_Close | |
|---|---|---|
| Date | ||
| 2010-01-04 | 1.442398 | 257.649994 |
| 2010-01-05 | 1.436596 | 257.589996 |
| 2010-01-06 | 1.440403 | 257.959991 |
| 2010-01-07 | 1.431803 | 258.040009 |
| 2010-01-08 | 1.441109 | 259.149994 |
| ... | ... | ... |
| 2023-04-24 | 1.099227 | 468.970001 |
| 2023-04-25 | 1.105950 | 467.079987 |
| 2023-04-26 | 1.097839 | 463.209991 |
| 2023-04-27 | 1.104728 | 464.029999 |
| 2023-04-28 | 1.103205 | 466.640015 |
3340 rows × 2 columns
Remove Outliers is done when the Z-score is greater than 3
# Calculating the z-scores of each data point
z_scores = np.abs((df - df.mean()) / df.std())
z_scores
| eur_usd_Adj_Close | stoxx_600_Adj_Close | |
|---|---|---|
| Date | ||
| 2010-01-04 | 2.100429 | 1.441932 |
| 2010-01-05 | 2.049478 | 1.442855 |
| 2010-01-06 | 2.082914 | 1.437162 |
| 2010-01-07 | 2.007390 | 1.435931 |
| 2010-01-08 | 2.089112 | 1.418851 |
| ... | ... | ... |
| 2023-04-24 | 0.913224 | 1.809653 |
| 2023-04-25 | 0.854186 | 1.780571 |
| 2023-04-26 | 0.925410 | 1.721024 |
| 2023-04-27 | 0.864915 | 1.733641 |
| 2023-04-28 | 0.878293 | 1.773801 |
3340 rows × 2 columns
# Removing any data point that has a z-score greater than 3 (this is just an example threshold)
df = df[(z_scores < 3).all(axis=1)]
# Displaying the resulting DataFrame without outliers
print(df)
eur_usd_Adj_Close stoxx_600_Adj_Close Date 2010-01-04 1.442398 257.649994 2010-01-05 1.436596 257.589996 2010-01-06 1.440403 257.959991 2010-01-07 1.431803 258.040009 2010-01-08 1.441109 259.149994 ... ... ... 2023-04-24 1.099227 468.970001 2023-04-25 1.105950 467.079987 2023-04-26 1.097839 463.209991 2023-04-27 1.104728 464.029999 2023-04-28 1.103205 466.640015 [3340 rows x 2 columns]
The issue of bad data has been addressed through the use of indexing and also missing values have been removed. Using a Monthly average, we can remove the issues of eliminating the data points
# Calculate monthly average values
monthly_data = df.resample('M').mean()
monthly_data
| eur_usd_Adj_Close | stoxx_600_Adj_Close | |
|---|---|---|
| Date | ||
| 2010-01-31 | 1.427301 | 254.591998 |
| 2010-02-28 | 1.368163 | 244.835001 |
| 2010-03-31 | 1.357616 | 258.789567 |
| 2010-04-30 | 1.342236 | 266.933501 |
| 2010-05-31 | 1.253770 | 246.439473 |
| ... | ... | ... |
| 2022-12-31 | 1.057865 | 433.432385 |
| 2023-01-31 | 1.077875 | 450.011430 |
| 2023-02-28 | 1.071893 | 461.045998 |
| 2023-03-31 | 1.070565 | 450.471739 |
| 2023-04-30 | 1.096335 | 464.212777 |
160 rows × 2 columns
Step 6
As a group, all cleaning methods get combined to produce a “sterilized” version of the data. The group collaboratively writes why certain data points/events/periods of time were eliminated from the model’s data.
In our analysis, we encountered situations where certain data points, events, or periods of time were eliminated from the cleaned data obtained from yfinance. This was mainly due to reasons such as incomplete data, data outliers, data inconsistencies, inaccurate data, and the need for data quality control.
Incomplete data was a common issue, as the data retrieved from Yahoo Finance through yfinance may not always provide complete data. As a result, some data points or periods of time may be missing, which can impact the accuracy of the data analysis. To address this, incomplete data was removed to ensure that the remaining data is accurate and representative.
Data outliers, which are values that are significantly different from other values in the dataset, can also affect the accuracy of data analysis. These outliers may occur due to errors, noise, or other factors. To ensure that the remaining data is representative of the dataset, outliers were removed.
Similarly, data inconsistencies, which occur when data points do not match or are in conflict with other data points in the dataset, were eliminated. Inconsistencies can be caused by errors, inaccuracies, or data entry mistakes, and their removal was necessary to ensure that the remaining data is accurate and representative.
Inaccurate data, which may be caused by errors, mistakes, or inaccuracies in the data source, can also affect the accuracy of the data analysis. Hence, inaccurate data was removed to ensure that the remaining data is accurate and representative.
Finally, eliminating certain data points, events, or periods of time may be part of a quality control process. This process ensures that the data is accurate, complete, and representative of the dataset. In our analysis, removing certain data points, events, or periods of time was necessary to ensure that the remaining data is accurate and representative.
The US Energy Information Administration (EIA) data is an essential resource for investigating the global price of oil due to its provision of information on crude oil prices, one of the key variables affecting this price. As the primary source of energy statistics and analysis for the US government, the EIA offers comprehensive data on energy production, consumption, and prices.
Within the framework of the current assignment, the EIA data on crude oil prices can serve as a useful proxy for determining the global price of oil. Given that crude oil is the most widely traded commodity in the world, its price is susceptible to the influence of various macroeconomic and geopolitical factors, including supply and demand dynamics, global economic growth, political instability, and natural disasters.
Through the analysis of the relationship between EIA crude oil price data and other macroeconomic and microeconomic variables, such as exchange rates of Euro to USD and stock prices of STOXX Europe 600, valuable insights can be gained on the factors impacting the global price of oil. This knowledge is of utmost significance for investors, policymakers, and industry analysts seeking to grasp the causes of oil price fluctuations.
x= list(zip(df['eur_usd_Adj_Close'], df['stoxx_600_Adj_Close'], oil_price['oil_price'], oil_price['Date']))
df2 = pd.DataFrame(x)
df2 = df2.rename(columns={0: 'eur_usd_Adj_Close', 1:'stoxx_600_Adj_Close', 2: 'oil_price', 3: 'Date' })
df2 = df2.set_index('Date')
df2
| eur_usd_Adj_Close | stoxx_600_Adj_Close | oil_price | |
|---|---|---|---|
| Date | |||
| Jan-2010 | 1.442398 | 257.649994 | 76.17 |
| Feb-2010 | 1.436596 | 257.589996 | 73.75 |
| Mar-2010 | 1.440403 | 257.959991 | 78.83 |
| Apr-2010 | 1.431803 | 258.040009 | 84.82 |
| May-2010 | 1.441109 | 259.149994 | 75.95 |
| ... | ... | ... | ... |
| Dec-2022 | 1.277090 | 255.610001 | 80.92 |
| Jan-2023 | 1.281197 | 258.470001 | 82.50 |
| Feb-2023 | 1.287996 | 257.600006 | 82.59 |
| Mar-2023 | 1.285645 | 253.899994 | 78.43 |
| Apr-2023 | 1.280803 | 252.149994 | 84.64 |
160 rows × 3 columns
# Calculate the correlation between the variables
corr_matrix = df2.corr()
corr_matrix
| eur_usd_Adj_Close | stoxx_600_Adj_Close | oil_price | |
|---|---|---|---|
| eur_usd_Adj_Close | 1.000000 | 0.348805 | 0.492717 |
| stoxx_600_Adj_Close | 0.348805 | 1.000000 | -0.163057 |
| oil_price | 0.492717 | -0.163057 | 1.000000 |
import matplotlib.dates as mdates
# Assuming your dataframe is named 'df'
fig = px.line(df2, x=df2.index, y='eur_usd_Adj_Close')
# Add a title to the chart
fig.update_layout(title_text='Time Series Chart of Euro to USD Exchange Rate from 2010 to 2023')
# Increase the size of the chart
fig.update_layout(height=900, width=900)
fig.show()
# Assuming your dataframe is named 'df'
fig = px.line(df2, x=df2.index, y='stoxx_600_Adj_Close')
# Add a title to the chart
fig.update_layout(title_text='Time Series Chart of Stoxx 600 from 2010 to 2023')
# Increase the size of the chart
fig.update_layout(height=800, width=900)
fig.show()
# Assuming your dataframe is named 'df'
fig = px.line(df2, x=df2.index, y='oil_price')
# Add a title to the chart
fig.update_layout(title_text='Time Series of Oil Price per Barrel from 2010 to 2023')
# Increase the size of the chart
fig.update_layout(height=800, width=900)
fig.show()
STEP 7
Run exploratory data analysis on the data. Each person addresses ALL datasets. a. Student A creates “distributional” plots. b. Student B creates “time series” plots. c. Student C creates “multivariate” plots (distributional and/or time series).
import seaborn as sns
# Plot the distribution of Euro to USD exchange rates
plt.figure(figsize=(19.20, 10.80))
sns.histplot(df2['eur_usd_Adj_Close'], kde=True)
plt.title('Distribution plots of Euro to USD Exchange Rates', fontsize = 30)
plt.xlabel('Exchange Rate', fontsize = 25)
plt.ylabel('Count', fontsize = 25)
plt.show()
# Plot the distribution of Euro to USD exchange rates
plt.figure(figsize=(19.20, 10.80))
sns.histplot(df2['stoxx_600_Adj_Close'], kde=True)
plt.title('Distribution of STOXX Europe 600 Stock Prices', fontsize = 30)
plt.xlabel('Stock Price', fontsize = 25)
plt.ylabel('Count', fontsize = 25)
plt.show()
To plot the multivariate plot, we can use the Z-scores to make us draw proper inference from it.
# Calculating the z-scores of each data point
z_scores = ((df2 - df2.mean())/df2.std())
z_scores
| eur_usd_Adj_Close | stoxx_600_Adj_Close | oil_price | |
|---|---|---|---|
| Date | |||
| Jan-2010 | 1.849496 | 0.476562 | -0.059183 |
| Feb-2010 | 1.762256 | 0.469633 | -0.151804 |
| Mar-2010 | 1.819506 | 0.512363 | 0.042625 |
| Apr-2010 | 1.690192 | 0.521605 | 0.271882 |
| May-2010 | 1.830117 | 0.649797 | -0.067603 |
| ... | ... | ... | ... |
| Dec-2022 | -0.636122 | 0.240963 | 0.122616 |
| Jan-2023 | -0.574372 | 0.571264 | 0.183088 |
| Feb-2023 | -0.472143 | 0.470789 | 0.186532 |
| Mar-2023 | -0.507498 | 0.043474 | 0.027315 |
| Apr-2023 | -0.580292 | -0.158634 | 0.264992 |
160 rows × 3 columns
# Assuming your dataframe is named 'df'
fig = px.line(z_scores)
# Add a title to the chart
fig.update_layout(title_text='Multivariate plot of the Exchange rate, relating with stock prices and oil prices')
fig.show()
sns.pairplot(z_scores)
<seaborn.axisgrid.PairGrid at 0x265b1159040>
QUESTION 8
df2
| eur_usd_Adj_Close | stoxx_600_Adj_Close | oil_price | |
|---|---|---|---|
| Date | |||
| Jan-2010 | 1.442398 | 257.649994 | 76.17 |
| Feb-2010 | 1.436596 | 257.589996 | 73.75 |
| Mar-2010 | 1.440403 | 257.959991 | 78.83 |
| Apr-2010 | 1.431803 | 258.040009 | 84.82 |
| May-2010 | 1.441109 | 259.149994 | 75.95 |
| ... | ... | ... | ... |
| Dec-2022 | 1.277090 | 255.610001 | 80.92 |
| Jan-2023 | 1.281197 | 258.470001 | 82.50 |
| Feb-2023 | 1.287996 | 257.600006 | 82.59 |
| Mar-2023 | 1.285645 | 253.899994 | 78.43 |
| Apr-2023 | 1.280803 | 252.149994 | 84.64 |
160 rows × 3 columns
# Compute daily returns of the adjusted close
df2['eur_usd_returns'] = df2["eur_usd_Adj_Close"].pct_change()
# Compute daily returns of the adjusted close
df2['stoxx_600_returns'] = df2["stoxx_600_Adj_Close"].pct_change()
# Compute daily returns of the adjusted close
df2['oil_price_returns'] = df2["oil_price"].pct_change()
df2.head()
| eur_usd_Adj_Close | stoxx_600_Adj_Close | oil_price | eur_usd_returns | stoxx_600_returns | oil_price_returns | |
|---|---|---|---|---|---|---|
| Date | ||||||
| Jan-2010 | 1.442398 | 257.649994 | 76.17 | NaN | NaN | NaN |
| Feb-2010 | 1.436596 | 257.589996 | 73.75 | -0.004022 | -0.000233 | -0.031771 |
| Mar-2010 | 1.440403 | 257.959991 | 78.83 | 0.002650 | 0.001436 | 0.068881 |
| Apr-2010 | 1.431803 | 258.040009 | 84.82 | -0.005971 | 0.000310 | 0.075986 |
| May-2010 | 1.441109 | 259.149994 | 75.95 | 0.006499 | 0.004302 | -0.104574 |
df3 = df2.dropna()
df3.head()
| eur_usd_Adj_Close | stoxx_600_Adj_Close | oil_price | eur_usd_returns | stoxx_600_returns | oil_price_returns | |
|---|---|---|---|---|---|---|
| Date | ||||||
| Feb-2010 | 1.436596 | 257.589996 | 73.75 | -0.004022 | -0.000233 | -0.031771 |
| Mar-2010 | 1.440403 | 257.959991 | 78.83 | 0.002650 | 0.001436 | 0.068881 |
| Apr-2010 | 1.431803 | 258.040009 | 84.82 | -0.005971 | 0.000310 | 0.075986 |
| May-2010 | 1.441109 | 259.149994 | 75.95 | 0.006499 | 0.004302 | -0.104574 |
| Jun-2010 | 1.451126 | 258.809998 | 74.76 | 0.006951 | -0.001312 | -0.015668 |
import plotly.graph_objects as go
df4 = df3[['eur_usd_returns']]
df4.index = pd.to_datetime(df4.index)
fig_eur_usd_Returns = px.scatter(df4,
width=1000, height=800, trendline='ols',
trendline_color_override='DeepPink',
marginal_y='histogram', title='Bi-Variate Normal of Euro to USD Returns')
fig_eur_usd_Returns.show()
df4 = df3[['stoxx_600_returns']]
df4.index = pd.to_datetime(df4.index)
fig_eur_usd_Returns = px.scatter(df4,
width=1000, height=800, trendline='ols',
trendline_color_override='DeepPink',
marginal_y='histogram', title='Bi-Variate Normal of STOXX Europe 600 Returns')
fig_eur_usd_Returns.show()
df4 = df3[['oil_price_returns']]
df4.index = pd.to_datetime(df4.index)
fig_eur_usd_Returns = px.scatter(df4,
width=1000, height=800, trendline='ols',
trendline_color_override='DeepPink',
marginal_y='histogram', title='Bi-Variate Normal of US OIL Price Returns')
fig_eur_usd_Returns.show()